package github.flandre.examplemod.common.guiblock.tileentity;

import com.mojang.datafixers.DSL;
import github.flandre.examplemod.common.energy.tileentity.FEDemoGeneratorTileEntity;
import github.flandre.examplemod.common.guiblock.block.ExampleBurnMachine;
import github.flandre.examplemod.examplemod;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ObjectHolder;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;

//机器实体，功能都在这里
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ExampleInscribarMachineTileEntity extends TileEntity implements ITickableTileEntity, INamedContainerProvider {

    public static final String NAME = "examplemod:inscribar_machine";

    @ObjectHolder(NAME)
    public static TileEntityType<FEDemoGeneratorTileEntity> TILE_ENTITY_TYPE;

    //机器实体注册
    @SubscribeEvent
    public static void onRegisterTileEntityType(@Nonnull RegistryEvent.Register<TileEntityType<?>> event)
    {
        event.getRegistry().register(TileEntityType.Builder.create(ExampleInscribarMachineTileEntity::new,ExampleBurnMachine.BLOCK)
                .build(DSL.remainderType()).setRegistryName(NAME));
    }

    public ExampleInscribarMachineTileEntity() {
        super(TILE_ENTITY_TYPE);
    }

    //保存
    @Override
    public void read(@NotNull BlockState state, CompoundNBT compound) {
        super.read(state, compound);
    }
    @Nonnull
    @Override
    public CompoundNBT write(@Nonnull CompoundNBT compound)
    {
        return super.write(compound);
    }

    //界面名
    @Override
    public ITextComponent getDisplayName() {
        return new TranslationTextComponent("gui." + examplemod.MODID + ".inscribar_container");
    }

    //创建界面
    @Nullable
    @Override
    public Container createMenu(int sycID, @NotNull PlayerInventory inventory, PlayerEntity player) {
        //todo 机器实体
        return null;
    }

    @Override
    public void tick() {

    }
}
